package com.ibeetl.admin.core.file;

import org.apache.commons.lang3.StringUtils;
import org.springframework.core.env.Environment;

import java.io.File;
import java.io.OutputStream;

public abstract class FileItem {
	
    protected Long id;
	protected String name;
	protected String path;
	protected String title;
	protected String url;
	
	public static String getRoot(Environment env) {
		String root = env.getProperty("localFile.root");
		if(StringUtils.isEmpty(root)) {
			String userDir = System.getProperty("user.dir");//当前工程路径
			root = userDir+File.separator+"filesystem";
		}
		return root;
	}
	
	boolean isTemp = false;
	
	public abstract OutputStream openOutpuStream();
	
	public abstract void copy(OutputStream os);

	public abstract File getFile();

	//获得图片的长宽比：长/宽
	public abstract String getImageRatio();
	
	public abstract boolean delete();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPath() {
		return path;
	}
	public void setPath(String path) {
		this.path = path;
	}

    public boolean isTemp() {
        return isTemp;
    }

    public void setTemp(boolean isTemp) {
        this.isTemp = isTemp;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	
}
